<?php 
$userLoggedIn = $session->read('Auth.User.id');
	//echo $this->requestAction('/categories/selectCatgeory/null',array('autoRender'=>1));
?>
<?php echo __("Selected Category")?>:<h3 id="selectedCategory"><?php echo isset($this->data['Category']['parent_label']) ? $this->data['Category']['parent_label'] :"";?></h3>
<div id='listing_ajaxify'>
</div>

<script src='/cms/js/jquery.scrollTo.js'></script>
<script type="text/javascript">
$(document).ready(function()
{
	userLoggedIn = "<?php echo $userLoggedIn?>";
});

var lastSelected = null;
function selectParent(obj,id)
{
	$('#CategoryParentId').val(id);	
	if(id)
	$('#category_'+id).addClass('selected-category');
	$('#category_'+lastSelected).removeClass('selected-category');
	lastSelected = id;
	if(id)
	{
		$('#selectedCategory').text($('#category_'+id+' > span.category-title').text());
		$.get(URL+'listings/add/'+id,function(data)
		{
			if(userLoggedIn)
			{
				$('#listing_ajaxify').html(data);
			}else
			{
				window.location = URL+'users/login';
			}
		});
	}
	else
	{
		$('#selectedCategory').text("None");
	}
	//$.scrollTo('#selectedCategory',800,{easing:'elasout'});
	$.scrollTo( '#selectedCategory',2000);
	return false;
}
</script>